package com.liu.Work;
import org.junit.Test;

import java.io.*;
import java.util.Properties;

public class HomeWork03 {
    public static void main(String[] args) throws IOException {
        String filePath = "D:\\java_code\\Io-study\\file\\src\\dog.properties";
        Properties properties = new Properties();
        properties.load(new FileReader(filePath));
        String o = properties.get("name") + "";
        int o1 = Integer.parseInt(properties.get("age") + "");
        String o2 = properties.get("color") + " ";
        Dog dog = new Dog(o, o1, o2);
        System.out.println(dog);


        String srcFilePath = "d:\\dog.data";
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(srcFilePath));
        objectOutputStream.writeObject(dog);
        objectOutputStream.close();
    }
    @Test 
    public void m1() throws IOException, ClassNotFoundException {
        String srcFilePath = "d:\\dog.data";
        ObjectInputStream obj = new ObjectInputStream(new FileInputStream(srcFilePath));
        Dog dog = (Dog)obj.readObject();
        System.out.println(dog);
        obj.close();
    }
}
